package com.deercrowing.takeaway.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.deercrowing.takeaway.vo.CategoriesPageVO;
import com.deercrowing.takeaway.vo.CategoriesVO;
import org.apache.ibatis.annotations.Mapper;
import com.deercrowing.takeaway.entity.CategoriesEntity;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * 分类表(Categories)表数据库访问层
 *
 * @author guoyongxiang
 * @since 2024-07-10 15:09:05
 */
@Mapper
public interface CategoriesMapper extends BaseMapper<CategoriesEntity> {

    /**
     * 查找所有分类
     *
     * @return
     */
    @Select("select * from tb_categories")
    List<CategoriesEntity> selectList();

    /**
     * 统计分类数量
     *
     * @return
     */
    Integer countCategoryNum(CategoriesPageVO categoriesPageVO);

    /**
     * 变更分类启用/禁用状态
     *
     * @param status
     * @param id
     */
    @Update("update tb_categories set status = #{status} where id = #{id}")
    void updateByStatus(Short status, Integer id);

    /**
     * 查找所有启用的分类
     *
     * @return
     */
    List<CategoriesEntity> selectListByStatus();

    /**
     * 根据搜索条件查询
     *
     * @param categoriesPageVO
     * @return
     */
    List<CategoriesEntity> selectListByCondition(CategoriesPageVO categoriesPageVO);

    /**
     * 根据分类查询
     *
     * @param type
     * @return
     */
    @Select("select id,name from tb_categories where type = #{type}")
    List<CategoriesEntity> selectListByType(Short type);
}

